// /common/js/utils/index.js

const modules = {}
const files = import.meta.glob('./modules/**/*.js', {
  eager: true
})

Object.keys(files).forEach(key => {
  const moduleName = key.replace(/^\.\/modules\/(.*?)\.js$/, '$1')
  const moduleExports = files[key]

  Object.keys(moduleExports).forEach(exportName => {
    if (typeof moduleExports[exportName] === 'function') {
      if (modules[exportName]) {
        console.warn(`Function name conflict: ${exportName} is already defined. Overwriting.`)
      }
      modules[exportName] = moduleExports[exportName]
    }
  })
})

/*
import utils from '@/common/js/utils/index.js'
utils.debounce()
*/
export default modules
